<template>
	<view>
		<view class="cont">
			<view class="ts1">{{Info.companyName}}</view>
			<view class="ts2">主营：{{Info.companyBusiness}}</view>
			<view class="ts2">电话：<span style="color: red;">{{Info.companyPhone}}</span></view>
			<view class="ts2">地址：{{Info.companyAddress}}</view>
		</view>
		<view class="cont_video" v-if="Info.companyVideo">
			<video class="video" :src="Info.companyVideo" :autoplay='false'></video>
		</view>
		<view class="cont_f" v-if="Info.companyContent">
			<mp-html :content="Info.companyContent" />
		</view>
		<view class="" style="height: 100rpx;">
			
		</view>
		<view class="btns">
			<view class="flex_img" @click="goindex">
				<image src="../../static/tabbar/index.png" mode=""></image>
			</view>
			<view class="" style="display: flex;">
				<view class="btn1" @click="addsc()">{{Info.favorite == 0?'添加收藏':'已收藏'}}</view>
				<view class="btn2" @click="callPhone">联系我们</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getCompanysInfo,getCompanyfavorite,removefavorite
	} from '@/common/http.api.js';
	export default {
		data() {
			return {
				 html: '<div>Hello World!</div>',
				 Info:{},
				 id:0
			};
		},
		onLoad(e) {
			console.log(e);
			this.id = e.id
			getCompanysInfo({id:this.id}).then(res=>{
				this.Info = res.data
			})
		},
		methods:{
			addsc(){
					if(this.Info.favorite == 0){
						getCompanyfavorite({companyId:this.Info.id}).then(res=>{
							if(res.code == 200){
								uni.showToast({
									title:'收藏成功',
									icon:'none'
								})
								getCompanysInfo({id:this.id}).then(res=>{
									this.Info = res.data
								})
							}
						})
					}else{
						removefavorite({companyId:this.Info.id}).then(res=>{
							if(res.code == 200){
								uni.showToast({
									title:'已取消',
									icon:'none'
								})
								getCompanysInfo({id:this.id}).then(res=>{
									this.Info = res.data
								})
							}
						})
						
					}

			},
			goindex(){
				uni.switchTab({
					url:'/pages/index/index'
				})
			},
			callPhone(){
				uni.makePhoneCall({
					phoneNumber:this.Info.companyPhone,
					success() {
					}
				});
			}
		}
	}
</script>

<style lang="less">
	page {
		background-color: #F0F0F1;
	}
.cont{
	padding: 40rpx;
	.ts1{
		margin: 20rpx auto 30rpx;
		text-align: center;
		color: #1A4878;
		font-weight: bold;
		font-size: 40rpx;
		border-bottom: 1px solid #888888;
		padding-bottom: 20rpx;
	}
	.ts2{
		color: #666666;
		font-size: 26rpx;
		line-height: 48rpx;
	}
}
.cont_video{
	width: 100%;
	background-color: #1A4878;
	height: 452rpx;
	padding: 46rpx 55rpx;
	box-sizing: border-box;
	.video{
		width: 640rpx;
		height: 360rpx;
	}
}
.cont_f{
	width: 100%;
	padding: 20rpx;
	box-sizing: border-box;
	margin-bottom: 100rpx;
}
.btns{
	display: flex;
	background-color: #fff;
	justify-content: space-between;
	padding: 40rpx 40rpx 60rpx 40rpx;
	width: 100%;
	position: fixed;
	box-sizing: border-box;
	bottom: 0%;
	.flex_img{
		width: 58rpx;
		height: 58rpx;
		image{
		width: 58rpx;
		height: 58rpx;
		}
	}
	.btn1{
		width: 160rpx;
		height: 60rpx;
		border: 1px solid #022B5F;
		font-size: 28rpx;
		text-align: center;
		line-height: 60rpx;
		border-radius: 10rpx;
		margin-right: 40rpx;
	}
	.btn2{
		width: 160rpx;
		height: 60rpx;
		background-color: #022B5F;
		font-size: 28rpx;
		text-align: center;
		line-height: 60rpx;
		border-radius: 10rpx;
		color: #fff;
	}
}
</style>
